package com.best.eureka.controller;

import com.best.eureka.client.ProviderClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.Resources;

/**
 * @author Jiang Akang
 * employeeId: BG435424
 * @date 2021/7/23
 **/
@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    @Value("${server.port}")
    String port;

    // 动态代理对象，内部远程调用服务生产者
    @Autowired
    ProviderClient providerClient;

    @GetMapping("/find/instance")
    public String service() {

        // 远程调用
        String providerResult = providerClient.service();
        String result = "consumer invoke: " + port + " | " + providerResult;

        System.out.println("****************" + result);

        return result;
    }
}
